<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<script src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script>
<style>
	.fl-left{float:left;}
	.fl-right{float:right;}
	.cl{clear:both; }
	.mrg-left-5{margin-left:5px;}
	.mrg-left-10{margin-left:10px;}
	.btn{width:80px;height:45px;border-radius:5px;background:red;color:white;border:none;cursor:pointer;}
	.btn:hover {font-size:15px;}
	
	.content{width:800px;height:600px;border:1px solid black;margin-top:0px;margin-left:250px;}
	.user{margin:0 auto;width:380px;height:auto;margin-top:200px;}
	.cen{margin-left:auto;margin-right:auto;text-align:center;width:100%;background:blue;}
</style>
</head>
<body>
	<div class="content">
		<h1 class="cen">xxx系统登录</h1>
		<div class="user">
			<form id="form1" action="user/login.json" method="post">
				用户名<b style="color:red">*</b>：<input type="text" name="userName" id="userName" onchange="valideName(this);" value=""><span class="alt" style="display:none;color:red;">${valid }</span><br/>
				密码<b style="color:red">*</b>：<input type="password" name="pwd" id="userPwd" value=""><br/>
				<input type="button" id="sub" value="登录"><br/>
				还没有账户？去<a href="reginer">注册</a>
			</form>
		</div>
	</div>
<script>
	function valideName(obj){
		obj = $(obj);
		if(undefined==obj.val()||''==obj.val()){
			$('.alt').html('请输入用户名');
            $('.alt').show();
            return ;
		}
	}
	$(function(){
		$('#userName').focus();
		$('#sub').click(function(){
			if(undefined==$('#userName').val()||''==$('#userName').val()
					||undefined==$('#userPwd').val()||''==$('#userPwd').val())
			{
				return ;
			}
			$('#form1').submit();
			/*
			$.ajax({
                type: "POST",
                url: "user/login",
                data: {
                	userName:$('#userName').val(),
                	userPwd:$('#userPwd').val()
                },
                timeout: 1800000,  //30分钟的超时时间
                async: false,
                success: function(opResult){
                    if('0000'==opResult.respCode){
                    	setCookie('hzb',opResult.cookie);
                    	window.location.href="main";
                    } else {
                        alert(opResult.respMsg);
                    }
                },
                error:function () {
                	alert('操作失败');
                }
            });*/
		})
	})
	//读取cookies 
	function getCookie(name) 
	{ 
	    var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
	 
	    if(arr=document.cookie.match(reg))
	 
	        return unescape(arr[2]); 
	    else 
	        return null; 
	}
	//写cookies
	function setCookie(name,value)
	{ 
	    var Days = 30; 
	    var exp = new Date(); 
	    exp.setTime(exp.getTime() + Days*24*60*60*1000); 
	    document.cookie = name + "="+ escape(value) + ";expires=" + exp.toGMTString(); 
	}
	//删除cookies 
	function delCookie(name) 
	{ 
	    var exp = new Date(); 
	    exp.setTime(exp.getTime() - 1); 
	    var cval=getCookie(name); 
	    if(cval!=null) 
	        document.cookie= name + "="+cval+";expires="+exp.toGMTString(); 
	}
</script>
</body>
</html>